package com.example.mianshi.mianshiv2;

/**
 * 排序线程，将一行行数据从队列中获取出来，处理放入TreeMap中
 */
public class SortFileThread implements Runnable{
    private MFile file;
    private DoWorkTemplate template;

    public SortFileThread(MFile file, DoWorkTemplate template){
        this.file = file;
        this.template = template;
    }

    @Override
    public void run() {
        if(template.concurrentHashMap.containsKey(file.getGroupId())){
            MFile oldFile = template.concurrentHashMap.get(file.getGroupId());
            if (oldFile.getQuota() > file.getQuota()) {//保留小的，替换小的
                template.concurrentHashMap.put(Integer.valueOf(file.getGroupId()), file);
            }
        }else{
            template.concurrentHashMap.put(Integer.valueOf(file.getGroupId()), file);
        }
    }

}
